*** REPLICATION DOCUMENT FOR BAS and STONE ISQ
* TABLE 1 in the paper
* run in Stata 18
* set working directory to the replication folder


use "BasStoneReplication.dta", clear

* This llik normalizes UV1 = 0 uI2=0. Needed for the ML model below
capture program drop partobs2_lf
program define partobs2_lf
        version 8.0
	args 	lnf uV2 uV3 uI3	
	tempvar pV pI 
	qui gen double `pI' = norm((`uI3')/sqrt(2))
	qui gen double `pV' = norm((`pI'*`uV3' + (1-`pI')*`uV2')/sqrt(2))

	qui replace `lnf' = ln(`pV') + ln(`pI')   if $ML_y1 == 1
	qui replace `lnf' = ln(1-`pV'*`pI') if $ML_y1 == 0
	qui replace `lnf' = ln(`pV') + ln(1-`pI') if $ML_y1 == 2
	qui replace `lnf' = ln(1-`pV') if $ML_y1 == 3	
end




* Table 1 in the paper (Full Model)
set more off
set seed 1234567

ml model lf partobs2_lf (uV2:stepdown3 = catr mil mtnest elf lnten idealpointdi) (uV3:stepdown3 =  interconfinc intraconfinc hostlev_mn gdppcgr gdppc totalnumberofcrisis2) (uI3: stepdown3 = mil idealpointdi upopr perspercap2 poltr pcatr lagout gdppc)
matrix inits = (3.249653,  2.372404, -.0104462, -1.129891, -7.330102,  2.317568,   55.6942, -1.557992,  .0550265,  .4624153, -7.680818, -.0256894,   .205055, -.0709777, -.8286697,  .4616707,   .938277,  .1427571, -.7341128, -2.035021,  1.352735,  .1079354, -.6019921)
ml init inits, copy skip
*ml search, r(5000)
ml maximize, difficult iterate(200)



* Table 1 in the paper (Baseline Model)
set more off
set seed 1234567

ml model lf partobs2_lf (uV2:stepdown3 = mil mtnest elf lnten) (uV3:stepdown3 =  interconfinc gdppc) (uI3: stepdown3 = poltr lagout gdppc)
matrix inits2 = (11.6465,   .2827817,    5.69251,  -13.31355,   110.5103,  -.2139654,  -.0250287,  -.5232163,  -.0615826,   2.991107,   .0113572,  -.6912859)
ml init inits2, copy skip
*ml search, r(5000)
ml maximize, difficult iterate(200)